package com.sgcc.ln.pmos.e_ln_home.adapter;

import android.content.Context;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.ln.pmos.e_ln_home.bean.DynamicNetBean;

public class PoliciesRegulationsAdapter extends BaseQuickAdapter<DynamicNetBean.DataDTO.ListDTO, BaseViewHolder> {

    private Context mContext;

    public PoliciesRegulationsAdapter(Context context) {
        super(R.layout.item_policiesregulations);
        mContext = context;
    }

    public interface OnItemClickListener {
        //条目点击
        void itemClickListener(int position, DynamicNetBean.DataDTO.ListDTO bean);
    }

    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.mOnItemClickListener = onItemClickListener;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, DynamicNetBean.DataDTO.ListDTO bean) {
        baseViewHolder.setText(R.id.tv_company_name, bean.getTitle());
//        int number = SPUtils.getInstance(bean.getTitle_Id()).getInt("number");
//        number = number == -1 ? 0 : number;
        baseViewHolder.setText(R.id.tv_left1, bean.getReadAmount() + "浏览");
        baseViewHolder.setText(R.id.tv_right1, bean.getOperateDate());

        baseViewHolder.getView(R.id.ll_content).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mOnItemClickListener != null) {
                    mOnItemClickListener.itemClickListener(getItemPosition(bean), bean);
                }
            }
        });
    }


}
